<?php 

include_once '../../function.php';


// var_dump($_FILES);exit;

if(!empty($_FILES)){

	$upload = current($_FILES);

	if($upload['error']==0){

		$allowType = ['jpg','png','gif','psd','cdr','swf','txt'];

		$fileType = explode('.', $upload['name']);

		$fileType = end($fileType);

		if(in_array($fileType , $allowType )){

			is_dir('./Images') ||  mkdir('./Images');

			$name = uniqid();

			if(move_uploaded_file($upload['tmp_name'],'./Images/'.$name.'.'.$fileType)){
				echo "上传成功";
			}else{
				echo "上传失败,新重新上传";
			}
		}else{
			echo "上传失败,类型不允许";
		}

	}else{
		echo "上传失败,错误代码：".$upload['error'];
	}

}else{
	echo "上传失败";
}

header("Location:./index.php");


























 ?>